package com.lagou.module3hw.hw5;

import java.util.Comparator;

/**
 * 纸牌由大到小排序
 */
public class ComparatorCard implements Comparator<String> {
    @Override
    public int compare(String s1, String s2) {
        //定义排序规则
        String[] str = {"大王","小王","2","A","K","Q","J","10","9","8","7","6","5","4","3"};
        int s1Index = 0;
        int s2Index = 0;
        for(int i = 0; i < str.length; i++ ){
            if(s1.indexOf(str[i]) >= 0){
                s1Index = i;
            }
            if(s2.indexOf(str[i]) >= 0){
                s2Index = i;
            }
        }

        return s1Index - s2Index;
    }
}
